﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class svc_Service : System.Web.UI.Page
{


    public string Action
    {
        get
        {
            return this.Request["action"];
        }
    }

    public string AppCode
    {
        get
        {   
            return this.Request["appcode"];
        }
    }

    public string Reckey
    {
        get
        {   
            return this.Request["reckey"];
        }
    }

    public string Data
    {
        get
        {   
            return this.Request["data"];
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        JsonResult result = new JsonResult();

        this.Response.ContentType = "application/json";

        if (this.Action == "drop")
        {

            if (string.IsNullOrWhiteSpace(this.AppCode) || string.IsNullOrWhiteSpace(this.Data) || string.IsNullOrWhiteSpace(this.Reckey))
            {
                result.success = false;
                result.message = "参数输入有误";
                
                this.Response.Write(result.ToString());

                return;
            }

            Maticsoft.BLL.bll_api_delay api_delay = new Maticsoft.BLL.bll_api_delay();
            var app = api_delay.GetModelByCacheWithAppCode(this.AppCode);

            if (app == null)
            {
                result.success = false;
                result.message = "没有检索到应用";

                this.Response.Write(result.ToString());

                return;
            }

            string messageId = MqUtil.Send2Quene(app.appqueue, this.Reckey, this.Data);
            
            GMS.Core.Log.Log4NetHelper.LogInput("投递任务", this.AppCode, app.appqueue, this.Reckey, this.Data,messageId);

            if (!string.IsNullOrWhiteSpace(messageId))
            {
                result.success = true;
                result.message = "投递任务成功";

                this.Response.Write(result.ToString());
            }
            else
            {
                result.success = false;
                result.message = "投递任务失败";

                this.Response.Write(result.ToString());
            }

        }
    }
}